package o;

import android.content.Context;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.util.Log;
import android.view.ActionProvider;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.MenuItem.OnActionExpandListener;
import android.view.MenuItem.OnMenuItemClickListener;
import android.view.SubMenu;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewDebug.CapturedViewProperty;
import android.widget.LinearLayout;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.d;
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
import o.bo.b;

@RestrictTo({d.LIBRARY_GROUP})
public final class bj implements gk {
    private int ʻ = 4096;
    private ColorStateList ʻॱ = null;
    private CharSequence ʼ;
    private boolean ʼॱ = false;
    private char ʽ;
    private boolean ʽॱ = false;
    private Mode ʾ = null;
    private int ʿ = 16;
    private boolean ˈ = false;
    private hd ˉ;
    private final int ˊ;
    private boolean ˊˊ = false;
    private int ˊˋ = 0;
    private int ˊॱ = 0;
    private OnActionExpandListener ˊᐝ;
    bd ˋ;
    private View ˋˊ;
    private bv ˋॱ;
    private ContextMenuInfo ˍ;
    private final int ˎ;
    private final int ˏ;
    private char ˏॱ;
    private Drawable ͺ;
    private final int ॱ;
    private int ॱˊ = 4096;
    private CharSequence ॱˋ;
    private Runnable ॱˎ;
    private CharSequence ॱॱ;
    private OnMenuItemClickListener ॱᐝ;
    private Intent ᐝ;
    private CharSequence ᐝॱ;

    public /* synthetic */ MenuItem setActionView(int i) {
        return ˋ(i);
    }

    public /* synthetic */ MenuItem setActionView(View view) {
        return ˋ(view);
    }

    public /* synthetic */ MenuItem setContentDescription(CharSequence charSequence) {
        return ˎ(charSequence);
    }

    public /* synthetic */ MenuItem setShowAsActionFlags(int i) {
        return ˏ(i);
    }

    public /* synthetic */ MenuItem setTooltipText(CharSequence charSequence) {
        return ˊ(charSequence);
    }

    bj(bd bdVar, int i, int i2, int i3, int i4, CharSequence charSequence, int i5) {
        this.ˋ = bdVar;
        this.ॱ = i2;
        this.ˊ = i;
        this.ˏ = i3;
        this.ˎ = i4;
        this.ʼ = charSequence;
        this.ˊˋ = i5;
    }

    public boolean ॱ() {
        if ((this.ॱᐝ != null && this.ॱᐝ.onMenuItemClick(this)) || this.ˋ.ॱ(this.ˋ, (MenuItem) this)) {
            return true;
        }
        if (this.ॱˎ != null) {
            this.ॱˎ.run();
            return true;
        }
        if (this.ᐝ != null) {
            try {
                this.ˋ.ᐝ().startActivity(this.ᐝ);
                return true;
            } catch (Throwable e) {
                Log.e("MenuItemImpl", "Can't find activity to handle intent; ignoring", e);
            }
        }
        if (this.ˉ == null || !this.ˉ.ˊ()) {
            return false;
        }
        return true;
    }

    public boolean isEnabled() {
        return (this.ʿ & 16) != 0;
    }

    public MenuItem setEnabled(boolean z) {
        if (z) {
            this.ʿ |= 16;
        } else {
            this.ʿ &= -17;
        }
        this.ˋ.ˎ(false);
        return this;
    }

    public int getGroupId() {
        return this.ˊ;
    }

    @CapturedViewProperty
    public int getItemId() {
        return this.ॱ;
    }

    public int getOrder() {
        return this.ˏ;
    }

    public int ˊ() {
        return this.ˎ;
    }

    public Intent getIntent() {
        return this.ᐝ;
    }

    public MenuItem setIntent(Intent intent) {
        this.ᐝ = intent;
        return this;
    }

    public char getAlphabeticShortcut() {
        return this.ˏॱ;
    }

    public MenuItem setAlphabeticShortcut(char c) {
        if (this.ˏॱ != c) {
            this.ˏॱ = Character.toLowerCase(c);
            this.ˋ.ˎ(false);
        }
        return this;
    }

    public MenuItem setAlphabeticShortcut(char c, int i) {
        if (!(this.ˏॱ == c && this.ॱˊ == i)) {
            this.ˏॱ = Character.toLowerCase(c);
            this.ॱˊ = KeyEvent.normalizeMetaState(i);
            this.ˋ.ˎ(false);
        }
        return this;
    }

    public int getAlphabeticModifiers() {
        return this.ॱˊ;
    }

    public char getNumericShortcut() {
        return this.ʽ;
    }

    public int getNumericModifiers() {
        return this.ʻ;
    }

    public MenuItem setNumericShortcut(char c) {
        if (this.ʽ != c) {
            this.ʽ = c;
            this.ˋ.ˎ(false);
        }
        return this;
    }

    public MenuItem setNumericShortcut(char c, int i) {
        if (!(this.ʽ == c && this.ʻ == i)) {
            this.ʽ = c;
            this.ʻ = KeyEvent.normalizeMetaState(i);
            this.ˋ.ˎ(false);
        }
        return this;
    }

    public MenuItem setShortcut(char c, char c2) {
        this.ʽ = c;
        this.ˏॱ = Character.toLowerCase(c2);
        this.ˋ.ˎ(false);
        return this;
    }

    public MenuItem setShortcut(char c, char c2, int i, int i2) {
        this.ʽ = c;
        this.ʻ = KeyEvent.normalizeMetaState(i);
        this.ˏॱ = Character.toLowerCase(c2);
        this.ॱˊ = KeyEvent.normalizeMetaState(i2);
        this.ˋ.ˎ(false);
        return this;
    }

    public char ˎ() {
        return this.ˋ.ˋ() ? this.ˏॱ : this.ʽ;
    }

    public String ˏ() {
        char ˎ = ˎ();
        if (ˎ == '\u0000') {
            return "";
        }
        Resources resources = this.ˋ.ᐝ().getResources();
        StringBuilder stringBuilder = new StringBuilder();
        if (ViewConfiguration.get(this.ˋ.ᐝ()).hasPermanentMenuKey()) {
            stringBuilder.append(resources.getString(ah$h.ͺ));
        }
        int i = this.ˋ.ˋ() ? this.ॱˊ : this.ʻ;
        ˋ(stringBuilder, i, WXMediaMessage.THUMB_LENGTH_LIMIT, resources.getString(ah$h.ᐝ));
        ˋ(stringBuilder, i, 4096, resources.getString(ah$h.ˋ));
        ˋ(stringBuilder, i, 2, resources.getString(ah$h.ॱ));
        ˋ(stringBuilder, i, 1, resources.getString(ah$h.ʽ));
        ˋ(stringBuilder, i, 4, resources.getString(ah$h.ˏॱ));
        ˋ(stringBuilder, i, 8, resources.getString(ah$h.ʻ));
        switch (ˎ) {
            case '\b':
                stringBuilder.append(resources.getString(ah$h.ॱॱ));
                break;
            case '\n':
                stringBuilder.append(resources.getString(ah$h.ʼ));
                break;
            case ' ':
                stringBuilder.append(resources.getString(ah$h.ˊॱ));
                break;
            default:
                stringBuilder.append(ˎ);
                break;
        }
        return stringBuilder.toString();
    }

    private static void ˋ(StringBuilder stringBuilder, int i, int i2, String str) {
        if ((i & i2) == i2) {
            stringBuilder.append(str);
        }
    }

    public boolean ॱॱ() {
        return this.ˋ.ˏ() && ˎ() != '\u0000';
    }

    public SubMenu getSubMenu() {
        return this.ˋॱ;
    }

    public boolean hasSubMenu() {
        return this.ˋॱ != null;
    }

    public void ˊ(bv bvVar) {
        this.ˋॱ = bvVar;
        bvVar.setHeaderTitle(getTitle());
    }

    @CapturedViewProperty
    public CharSequence getTitle() {
        return this.ʼ;
    }

    public CharSequence ˏ(b bVar) {
        if (bVar == null || !bVar.a_()) {
            return getTitle();
        }
        return getTitleCondensed();
    }

    public MenuItem setTitle(CharSequence charSequence) {
        this.ʼ = charSequence;
        this.ˋ.ˎ(false);
        if (this.ˋॱ != null) {
            this.ˋॱ.setHeaderTitle(charSequence);
        }
        return this;
    }

    public MenuItem setTitle(int i) {
        return setTitle(this.ˋ.ᐝ().getString(i));
    }

    public CharSequence getTitleCondensed() {
        CharSequence charSequence = this.ॱॱ != null ? this.ॱॱ : this.ʼ;
        if (VERSION.SDK_INT >= 18 || charSequence == null || (charSequence instanceof String)) {
            return charSequence;
        }
        return charSequence.toString();
    }

    public MenuItem setTitleCondensed(CharSequence charSequence) {
        this.ॱॱ = charSequence;
        if (charSequence == null) {
            CharSequence charSequence2 = this.ʼ;
        }
        this.ˋ.ˎ(false);
        return this;
    }

    public Drawable getIcon() {
        if (this.ͺ != null) {
            return ˋ(this.ͺ);
        }
        if (this.ˊॱ == 0) {
            return null;
        }
        Drawable ˋ = ar.ˋ(this.ˋ.ᐝ(), this.ˊॱ);
        this.ˊॱ = 0;
        this.ͺ = ˋ;
        return ˋ(ˋ);
    }

    public MenuItem setIcon(Drawable drawable) {
        this.ˊॱ = 0;
        this.ͺ = drawable;
        this.ˈ = true;
        this.ˋ.ˎ(false);
        return this;
    }

    public MenuItem setIcon(int i) {
        this.ͺ = null;
        this.ˊॱ = i;
        this.ˈ = true;
        this.ˋ.ˎ(false);
        return this;
    }

    public MenuItem setIconTintList(@Nullable ColorStateList colorStateList) {
        this.ʻॱ = colorStateList;
        this.ʽॱ = true;
        this.ˈ = true;
        this.ˋ.ˎ(false);
        return this;
    }

    public ColorStateList getIconTintList() {
        return this.ʻॱ;
    }

    public MenuItem setIconTintMode(Mode mode) {
        this.ʾ = mode;
        this.ʼॱ = true;
        this.ˈ = true;
        this.ˋ.ˎ(false);
        return this;
    }

    public Mode getIconTintMode() {
        return this.ʾ;
    }

    private Drawable ˋ(Drawable drawable) {
        if (drawable != null && this.ˈ && (this.ʽॱ || this.ʼॱ)) {
            drawable = gg.ʻ(drawable).mutate();
            if (this.ʽॱ) {
                gg.ॱ(drawable, this.ʻॱ);
            }
            if (this.ʼॱ) {
                gg.ˋ(drawable, this.ʾ);
            }
            this.ˈ = false;
        }
        return drawable;
    }

    public boolean isCheckable() {
        return (this.ʿ & 1) == 1;
    }

    public MenuItem setCheckable(boolean z) {
        int i = this.ʿ;
        this.ʿ = (z ? 1 : 0) | (this.ʿ & -2);
        if (i != this.ʿ) {
            this.ˋ.ˎ(false);
        }
        return this;
    }

    public void ॱ(boolean z) {
        this.ʿ = (z ? 4 : 0) | (this.ʿ & -5);
    }

    public boolean ʼ() {
        return (this.ʿ & 4) != 0;
    }

    public boolean isChecked() {
        return (this.ʿ & 2) == 2;
    }

    public MenuItem setChecked(boolean z) {
        if ((this.ʿ & 4) != 0) {
            this.ˋ.ˊ((MenuItem) this);
        } else {
            ˏ(z);
        }
        return this;
    }

    void ˏ(boolean z) {
        int i;
        int i2 = this.ʿ;
        int i3 = this.ʿ & -3;
        if (z) {
            i = 2;
        } else {
            i = 0;
        }
        this.ʿ = i | i3;
        if (i2 != this.ʿ) {
            this.ˋ.ˎ(false);
        }
    }

    public boolean isVisible() {
        if (this.ˉ == null || !this.ˉ.ˋ()) {
            if ((this.ʿ & 8) != 0) {
                return false;
            }
            return true;
        } else if ((this.ʿ & 8) == 0 && this.ˉ.ˎ()) {
            return true;
        } else {
            return false;
        }
    }

    boolean ˋ(boolean z) {
        int i = this.ʿ;
        this.ʿ = (z ? 0 : 8) | (this.ʿ & -9);
        if (i != this.ʿ) {
            return true;
        }
        return false;
    }

    public MenuItem setVisible(boolean z) {
        if (ˋ(z)) {
            this.ˋ.ˏ(this);
        }
        return this;
    }

    public MenuItem setOnMenuItemClickListener(OnMenuItemClickListener onMenuItemClickListener) {
        this.ॱᐝ = onMenuItemClickListener;
        return this;
    }

    public String toString() {
        return this.ʼ != null ? this.ʼ.toString() : null;
    }

    void ˋ(ContextMenuInfo contextMenuInfo) {
        this.ˍ = contextMenuInfo;
    }

    public ContextMenuInfo getMenuInfo() {
        return this.ˍ;
    }

    public void ᐝ() {
        this.ˋ.ˊ(this);
    }

    public boolean ʽ() {
        return this.ˋ.ʻॱ();
    }

    public boolean ʻ() {
        return (this.ʿ & 32) == 32;
    }

    public boolean ˏॱ() {
        return (this.ˊˋ & 1) == 1;
    }

    public boolean ॱˊ() {
        return (this.ˊˋ & 2) == 2;
    }

    public void ˊ(boolean z) {
        if (z) {
            this.ʿ |= 32;
        } else {
            this.ʿ &= -33;
        }
    }

    public boolean ˋॱ() {
        return (this.ˊˋ & 4) == 4;
    }

    public void setShowAsAction(int i) {
        switch (i & 3) {
            case 0:
            case 1:
            case 2:
                this.ˊˋ = i;
                this.ˋ.ˊ(this);
                return;
            default:
                throw new IllegalArgumentException("SHOW_AS_ACTION_ALWAYS, SHOW_AS_ACTION_IF_ROOM, and SHOW_AS_ACTION_NEVER are mutually exclusive.");
        }
    }

    public gk ˋ(View view) {
        this.ˋˊ = view;
        this.ˉ = null;
        if (view != null && view.getId() == -1 && this.ॱ > 0) {
            view.setId(this.ॱ);
        }
        this.ˋ.ˊ(this);
        return this;
    }

    public gk ˋ(int i) {
        Context ᐝ = this.ˋ.ᐝ();
        ˋ(LayoutInflater.from(ᐝ).inflate(i, new LinearLayout(ᐝ), false));
        return this;
    }

    public View getActionView() {
        if (this.ˋˊ != null) {
            return this.ˋˊ;
        }
        if (this.ˉ == null) {
            return null;
        }
        this.ˋˊ = this.ˉ.ॱ(this);
        return this.ˋˊ;
    }

    public MenuItem setActionProvider(ActionProvider actionProvider) {
        throw new UnsupportedOperationException("This is not supported, use MenuItemCompat.setActionProvider()");
    }

    public ActionProvider getActionProvider() {
        throw new UnsupportedOperationException("This is not supported, use MenuItemCompat.getActionProvider()");
    }

    public hd ˋ() {
        return this.ˉ;
    }

    public gk ˎ(hd hdVar) {
        if (this.ˉ != null) {
            this.ˉ.ʼ();
        }
        this.ˋˊ = null;
        this.ˉ = hdVar;
        this.ˋ.ˎ(true);
        if (this.ˉ != null) {
            this.ˉ.ˋ(new hd.d(this) {
                final /* synthetic */ bj ˊ;

                {
                    this.ˊ = r1;
                }

                public void ˏ(boolean z) {
                    this.ˊ.ˋ.ˏ(this.ˊ);
                }
            });
        }
        return this;
    }

    public gk ˏ(int i) {
        setShowAsAction(i);
        return this;
    }

    public boolean expandActionView() {
        if (!ˊॱ()) {
            return false;
        }
        if (this.ˊᐝ == null || this.ˊᐝ.onMenuItemActionExpand(this)) {
            return this.ˋ.ˋ(this);
        }
        return false;
    }

    public boolean collapseActionView() {
        if ((this.ˊˋ & 8) == 0) {
            return false;
        }
        if (this.ˋˊ == null) {
            return true;
        }
        if (this.ˊᐝ == null || this.ˊᐝ.onMenuItemActionCollapse(this)) {
            return this.ˋ.ˎ(this);
        }
        return false;
    }

    public boolean ˊॱ() {
        if ((this.ˊˋ & 8) == 0) {
            return false;
        }
        if (this.ˋˊ == null && this.ˉ != null) {
            this.ˋˊ = this.ˉ.ॱ(this);
        }
        if (this.ˋˊ != null) {
            return true;
        }
        return false;
    }

    public void ˎ(boolean z) {
        this.ˊˊ = z;
        this.ˋ.ˎ(false);
    }

    public boolean isActionViewExpanded() {
        return this.ˊˊ;
    }

    public MenuItem setOnActionExpandListener(OnActionExpandListener onActionExpandListener) {
        this.ˊᐝ = onActionExpandListener;
        return this;
    }

    public gk ˎ(CharSequence charSequence) {
        this.ॱˋ = charSequence;
        this.ˋ.ˎ(false);
        return this;
    }

    public CharSequence getContentDescription() {
        return this.ॱˋ;
    }

    public gk ˊ(CharSequence charSequence) {
        this.ᐝॱ = charSequence;
        this.ˋ.ˎ(false);
        return this;
    }

    public CharSequence getTooltipText() {
        return this.ᐝॱ;
    }
}
